﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for MerchantCarDriverDB
/// </summary>
namespace CE.CarInsurance
{
    public class MerchantCarDriverDB
    {
        public Int64 Insert(MerchantCarDriver merchantcardriver)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocMerchantCarDriverInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@CarDriverId", merchantcardriver.CarDriverId);
            _sPara.Add("@CarId", merchantcardriver.CarId);
            _sPara.Add("@RefCEUserId", merchantcardriver.RefCEUserId);
            _sPara.Add("@AgentId", merchantcardriver.AgentId);
            _sPara.Add("@FullName", merchantcardriver.FullName);
            _sPara.Add("@DOB", merchantcardriver.DOB);
            _sPara.Add("@IDNo", merchantcardriver.IDNo);
            _sPara.Add("@LicenseNumber", merchantcardriver.DrivingLicenseNumber);
            _sPara.Add("@Status", merchantcardriver.Status);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public Int64 Delete(Int64 CarDriverId, Int64 CarId, Int64 RefCEUserId)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocMerchantCarDriverDeleteSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@CarDriverId", CarDriverId);
            _sPara.Add("@FleetCarId", CarId);
            _sPara.Add("@RefCEUserId", RefCEUserId);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataTable GetCarDriverList(Int64 CarId, int Status)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            string _spName = "sprocMerchantCarDriverDetailSelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@CarId", CarId);
            _spara.Add("@Status", Status);

            DataTable _dt = _db.GetDataTableBySP(_spName, _spara);
            return _dt;
        }
    }
}
